﻿using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Adds multiple members to a list
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.ListToolbox.bmp")]
    [Designer(typeof(ListDesigner))]
    [Description("Adds multiple members to a list.")]
    public class AddMembersToList : TwitterOperationInvoker<object>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AddMembersToList"/> class.
        /// </summary>
        public AddMembersToList()
            : base("AddMembersToList")
        {
        }

        /// <summary>
        /// The numerical id of the list.
        /// <remarks>Required Argument</remarks>
        /// </summary>
        /// <value>
        /// The list ID.
        /// </value>
        [Browsable(true)]
        [Category("Properties")]
        [RequiredArgument]
        [Description("The numerical id of the list.")]
        public InArgument<long> ListID { get; set; }

        /// <summary>
        /// A comma separated list of screen names, up to 100 are allowed in a single request.
        /// <remarks>Required Argument</remarks>
        /// </summary>
        /// <value>
        /// The usernames.
        /// </value>
        [Browsable(true)]
        [Category("Properties")]
        [RequiredArgument]
        [Description("A comma separated list of screen names, up to 100 are allowed in a single request.")]
        public InArgument<string> UserNames { get; set; }


        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(System.Activities.NativeActivityMetadata metadata)
        {
            RuntimeArgument listIDArgument = new RuntimeArgument("ListID", typeof(long), ArgumentDirection.In, true);
            metadata.Bind(ListID, listIDArgument);
            metadata.AddArgument(listIDArgument);

            RuntimeArgument userNamesArgument = new RuntimeArgument("UserNames", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(UserNames, userNamesArgument);
            metadata.AddArgument(userNamesArgument);

            base.CacheMetadata(metadata);
        }

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(System.Activities.NativeActivityContext context)
        {
            Parameters.Clear();

            Parameters.Add("listID", ListID);
            Parameters.Add("usernames", UserNames);

            base.Execute(context);
        }
    }
}
